//do log lin test for KKPS
clear all
set more off

use "$datadir\kkps_dat.dta", clear
set seed 1234

// estimate the model in LogOLS 
qui reg	lognetinc ydum1-ydum11 ydum13-ydum20 loginc [aw = hweight] 	if age<65 & landlord != 1
keep if e(sample)




//do  test of appropriateness of log linearization

poisson netinc ydum1-ydum11 ydum13-ydum20 loginc [iw = hweight], robust
predict fit, ir

gen lfit=log(fit)
gen lscore=log((netinc-fit)^2)
 
reg lscore lfit, r
sca b=_b[lfit]
sca se=_se[lfit]
test lfit=2

mat A=[b,se,r(F),r(p)]
putexcel set "${res}\Log_Lin_Test", sheet(1) replace
putexcel A1=matrix(A)




